<!--
 * ============LICENSE_START=======================================================
 * SDC
 * ================================================================================
 * Copyright (C) 2020 Nordix Foundation. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
-->

<div class="app-capabilities-filter-properties-editor">
  <form class="w-sdc-form">
    <loader [display]="isLoading" [size]="'large'" [relative]="true"></loader>
    <div class="i-sdc-form-content">
      <div class="rule-builder-content">
        <div class="i-sdc-form-item rule-input-field">
          <label class="i-sdc-form-label required">{{currentServiceName}} Capabilities</label>
          <ui-element-dropdown class="i-sdc-form-select" class="rule-assigned-value"
                               [(value)]="currentRule.capabilityName"
                               [values]="capabilitiesNames"
                               (elementChanged)="onCapabilityNameChanged($event.value)">
          </ui-element-dropdown>
        </div>

        <div class="i-sdc-form-item rule-input-field">
          <label class="i-sdc-form-label required">Capability Properties</label>
          <ui-element-dropdown class="i-sdc-form-select" class="rule-assigned-value"
                               [(value)]="this.currentRule.servicePropertyName"
                               [values]="capabilityProperties"
                               (change)="onServicePropertyChanged()">
          </ui-element-dropdown>
        </div>

        <div class="i-sdc-form-item rule-input-field operator">
          <ui-element-dropdown class="i-sdc-form-select"
                               [values]="operatorTypes"
                               [(value)]="currentRule.constraintOperator">
          </ui-element-dropdown>
        </div>

        <div class="i-sdc-form-item rule-input-field">
          <label class="i-sdc-form-label required" >Source</label>
          <ui-element-dropdown class="i-sdc-form-select"
                               [values]="sourceTypes"
                               [(value)]="currentRule.sourceName"
                               (change)="onSelectSourceType()">
          </ui-element-dropdown>
        </div>

        <div class="rule-input-field assigned-value-field">
          <label class="i-sdc-form-label required" >{{assignedValueLabel}}</label>
          <dynamic-element
              *ngIf="currentRule.sourceType === SOURCE_TYPES.STATIC.value"
              [(value)]="currentRule.value"
              class="rule-assigned-value"
              data-tests-id="ruleAssignedValue"
              (elementChanged)="onValueChange($event.isValid)"
              [type]="selectedCapabilitiesPropertyObject ? selectedCapabilitiesPropertyObject.type : 'string'">
          </dynamic-element>
          <ui-element-dropdown *ngIf="currentRule.sourceType !== SOURCE_TYPES.STATIC.value"
                               class="rule-assigned-value"
                               data-tests-id="ruleAssignedValue"
                               [(value)]="currentRule.value"
                               [values]="listOfValuesToAssign">
          </ui-element-dropdown>
        </div>
      </div>
    </div>
  </form>

</div>
